package com.self.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.self.member.mapper.UserAuthInfoMapper;
import com.self.member.model.UserAuthInfo;
import com.self.member.service.UserAuthInfoService;
import org.springframework.stereotype.Service;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

@Service
public class UserAuthInfoServiceImpl extends ServiceImpl<UserAuthInfoMapper, UserAuthInfo> implements UserAuthInfoService {

    @Override
    public List<UserAuthInfo> getUserAuthInfoByUserId(Long id) {
        return list(new LambdaQueryWrapper<UserAuthInfo>()
                .eq(id != null,UserAuthInfo::getUserId,id)
                .orderByDesc(UserAuthInfo::getCreated).last(" limit 3"));
    }

    @Override
    public List<UserAuthInfo> getUserAuthInfoListByAuthCode(Long authCode) {
        return list(new LambdaQueryWrapper<UserAuthInfo>()
                .eq(authCode != null,UserAuthInfo::getAuthCode,authCode));
    }
}
